// @before-stub-for-debug-begin
#include <vector>
#include <string>
#include "commoncppproblem509.h"

using namespace std;
// @before-stub-for-debug-end

/*
 * @lc app=leetcode.cn id=509 lang=cpp
 *
 * [509] 斐波那契数
 */

// @lc code=start
class Solution {
public:
    int fib(int n) {
        if (n < 2) return n;
        int a = 0;
        int b = 1;
        for (int i = 1; i < n; i++) {
            int tmp = a + b;
            a = b;
            b = tmp;
        }
        return b;
    }
};
// @lc code=end

